package me.zhengjie.minbearwcs.controller.shifting;

import lombok.RequiredArgsConstructor;
import me.zhengjie.minbearwcs.entity.DTO.response.RespWithObject;
import me.zhengjie.minbearwcs.entity.DTO.transfer.Tuple;
import me.zhengjie.minbearwcs.serivce.shifting.ShiftingService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequiredArgsConstructor
@RequestMapping("/pda/shifting")
public class ShiftingPdaController {

    private final ShiftingService shiftingService;

    @PostMapping("/call")
    public RespWithObject<Void> receiveShiftingMission(@RequestBody Map<String, String> infoReq) {
        String palletCode = infoReq.get("palletCode");
        Tuple<String> stringTuple = shiftingService.receiveShiftingMission(palletCode);
        return new RespWithObject<Void>()
                .code(stringTuple.success)
                .reason(stringTuple.value);
    }
}
